<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php
	$USER = getAccountUserObject();
	$countUnread = $this->escort_message_thread_entity->countAllUnreadMessagesOfUser($USER->getId(),USER_TYPE_AGENT);	 
	$escort_id = intval($this->input->get('escort_id',TRUE));
	$ESCORT = $this->escort_entity->init('id',$escort_id);
	
	if($ESCORT){
		if($ESCORT->getUserId() != getAccountUserId()){
			show_404();
		}
	}
?>
<div id="content-right">
	<div class="content-right-column">
		<ul>
			<li><a href="<?php echo site_url_lang("agent/account/messages");?>"><span class="unread_number"><?php echo $countUnread;?></span> <?php echo language_translate('right_nav_unread_message');?></a></li>
			<li><a href="<?php echo site_url_lang("agent/account/edit");?>"><?php echo language_translate('right_nav_edit_account');?></a></li>
		<!--	<li><a href="#">Payment data</a></li>	
			<li><a href="#">My wallet (325€)</a></li>-->
			<li><a href="<?php echo site_url_lang("agent/account/payment_history");?>"><?php echo language_translate('right_nav_payment_history');?></a></li>
			<li><a href="<?php echo site_url_lang("agent/account/services");?>"><?php echo language_translate('right_nav_account_services');?></a></li>
			<li><a href="<?php echo site_url_lang("agent/account/support");?>"><?php echo language_translate('right_nav_support');?></a></li>
			<li><a href="<?php echo site_url_lang("agent/account/log_actions");?>"><?php echo language_translate('right_nav_log_actions');?></a></li>
		</ul>
	</div>
	<div class="clear"></div>
	
	<?php if($ESCORT):?>
		<div class="item-publish2 ui-corner-all" rel="<?php echo $ESCORT->getId();?>">
			<?php 
				if($ESCORT->getApplyServices() == 1){
					echo language_translate('agent_dashboard_info_unpublish');
				}else{
					echo language_translate('agent_dashboard_info_publish');
				}
			?>
		</div>
		<div class="clear"></div>
		
		<div class="item-publish-info2" rel="<?php echo $ESCORT->getId();?>">
			<?php 
				if($ESCORT->getPublished() != 1 AND $ESCORT->getApplyServices() == 1){
					echo language_translate('agent_dashboard_info_publish_info');
				}
			?>			
		</div>
		<div class="clear"></div>
		
		<div class="item-delete-escort ui-corner-all" rel="<?php echo $ESCORT->getId();?>">
			<?php 
				echo language_translate('agent_dashboard_info_delete');
			?>
		</div>
	<?php endif;?>
	
	<div class="clear"></div>
	<div class="content-right-column">
		<?php $this->load->view('banner/right_banner',array('pos'=>'agent') ); ?>
	</div>
</div>
<div class="clear"></div>

<div class="bottom-content-wrapper">
	<?php $this->load->view('news/list_news',array('pos'=>'agent') ); ?>
</div>

<div class="bottom-content-wrapper">
	<?php $this->load->view('banner/bottom_banner',array('pos'=>'agent') ); ?>
</div> 

<script type="text/javascript">
	$(document).ready(function(){
		$('.item-publish2').bind('click',function(){
			$id = $(this).attr('rel');
			$this = this;
			$('#greyDiv').show();
			$.post(BASE_URI+'agent/my_account/publish_escort',{id:$id},function(res){
				$('#greyDiv').hide();
				if(res.result == 'ok'){
					$($this).text(res.message);
					$('.item-publish-info2[rel='+$id+']').text(res.info);
				}else{
					alert(res.message);
				}
			},'json');
		});

		$('.item-delete-escort').bind('click',function(){
			$id = $(this).attr('rel');
			if(confirm("<?php echo language_translate('delete_escort_confirm');?>")){
				$('#greyDiv').show();
				$.post(BASE_URI+'agent/my_account/delete_escort',{id:$id},function(res){
					queryurl(BASE_URI+'agent/my_profile');
				});
			}
		});
	});
</script>